package com.engine.workflow.cmd.requestLog;

import com.api.doc.detail.service.DocViewPermission;
import com.api.doc.detail.util.DocDownloadCheckUtil;
import com.api.workflow.constant.RequestAuthenticationConstant;
import com.api.workflow.service.RequestAuthenticationService;
import com.api.workflow.util.ServiceUtil;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.constant.ParamConstant;
import com.engine.common.entity.BizLogContext;
import com.engine.common.util.AttrSignatureUtil;
import com.engine.core.interceptor.CommandContext;
import com.engine.hrm.biz.OrganizationShowSetBiz;
import com.engine.workflow.biz.QysSignatureCominfo;
import com.engine.workflow.biz.RequestLogBiz;
import com.engine.workflow.biz.RobotNode.RobotNodeBiz;
import com.engine.workflow.biz.RobotNode.RobotNodeServiceBiz;
import com.engine.workflow.biz.SecondAuthBiz;
import com.engine.workflow.biz.WorkflowCommunicationBiz;
import com.engine.workflow.biz.freeNode.FreeNodeBiz;
import com.engine.workflow.biz.requestForm.RequestFormBiz;
import com.engine.workflow.constant.SecondAuthType;
import com.engine.workflow.constant.SignSource;
import com.engine.workflow.constant.menu.SystemMenuType;
import com.engine.workflow.constant.requestForm.RequestConstant;
import com.engine.workflow.entity.requestForm.RightMenu;
import com.engine.workflow.service.RequestSecondAuthService;
import com.engine.workflow.service.impl.RequestSecondAuthServiceImpl;
import com.engine.workflow.util.MenuOrderSetUtil;
import com.google.common.base.Strings;
import weaver.conn.RecordSet;
import weaver.crm.Maint.CustomerInfoComInfo;
import weaver.dateformat.DateTransformer;
import weaver.dateformat.UnifiedConversionInterface;
import weaver.docs.category.SecCategoryComInfo;
import weaver.docs.docs.DocImageManager;
import weaver.docs.webservices.DocAttachment;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import weaver.workflow.request.RequestLogOperateName;
import weaver.workflow.request.RequestRemarkRight;
import weaver.workflow.request.WFLinkInfo;
import weaver.workflow.request.WorkflowSpeechAppend;
import weaver.workflow.workflow.WorkflowAllComInfo;
import weaver.workflow.workflow.WorkflowConfigComInfo;
import weaver.workflow.workflow.WorkflowRequestComInfo;
import com.api.odoc.util.OdocFileUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 获取签字意见列表数据
 * Created by jhy on 2018/4/10.
 */
public class LoadRequestLogDataCmd extends AbstractCommonCommand<Map<String, Object>> {

    /***方便使用参数***/
    private int requestid;
    private int workflowid;
    private int nodeid;
    private int desrequestid;
    private int isrequest;
    private boolean isprint;
    private boolean isworkflowhtmldoc;
    private String f_weaver_belongto_userid;
    private String f_weaver_belongto_usertype;
    private String source=""; //添加参数，用于转pdf复用此cmd

    private AttrSignatureUtil attrSignatureUtil;
    private String authSignatureInfo;
    private String authStr;
    private String authSignatureStr;

    private ResourceComInfo ResourceComInfo;
    private DepartmentComInfo DepartmentComInfo;
    private CustomerInfoComInfo CustomerInfoComInfo;

    private HttpServletRequest request;

    public LoadRequestLogDataCmd(HttpServletRequest request, User user, Map<String, Object> params) {
        this.request = request;
        this.user = user;
        this.params = params;
    }
    public LoadRequestLogDataCmd(HttpServletRequest request, User user, Map<String, Object> params,String source) {
        this.request = request;
        this.user = user;
        this.params = params;
        this.source =source;
    }

    public LoadRequestLogDataCmd(User user, Map<String, Object> params,String source) {
        this.user = user;
        this.params = params;
        this.source =source;
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        return executeTransfer();
    }

    public Map<String, Object> executeTransfer(){
        requestid = Util.getIntValue(Util.null2String(params.get("requestid")));
        f_weaver_belongto_userid = Util.null2String(params.get("f_weaver_belongto_userid"));
        f_weaver_belongto_usertype = Util.null2String(params.get("f_weaver_belongto_usertype"));
        attrSignatureUtil = new AttrSignatureUtil(user.getUID(), Util.null2String(params.get(ParamConstant.REQUEST_HEADER_USER_AGENT)));
        String _attributesString = Util.null2String(params.get(RequestConstant.SIGNATURE_ATTRIBUTES_STR));
        String _attributesSignature = Util.null2String(params.get(RequestConstant.SIGNATURE_SECRET_KEY));
        Map<String, Object> apidatas = new HashMap<String, Object>();
        if ("".equals(source)){
            attrSignatureUtil.verifySignature(_attributesString, _attributesSignature);
            //校验本次请求的requestid是否是当前用户打开的流程
            RequestAuthenticationService authService = new RequestAuthenticationService();
            authService.setUser(user);
            if (!authService.verify(request, requestid)) {
                new BaseBean().writeLog("被拦截：LoadRequestLogDataCmd；requestid：" + requestid);
                apidatas.put(Util.null2String(requestid),"被拦截：LoadRequestLogDataCmd");
                return apidatas;
            }
            authStr = authService.getAuthString();
            authSignatureStr= authService.getAuthSignatureString();
            authSignatureInfo = "&authStr=" + authService.getAuthString()+ "&authSignatureStr=" + authService.getAuthSignatureString();
        } else {
            authStr = Util.null2String(params.get(RequestAuthenticationConstant.AUTHORITY_STRING));
            authSignatureStr= Util.null2String(params.get(RequestAuthenticationConstant.AUTHORITY_SIGNATURESTRING));
            authSignatureInfo = "&authStr=" + Util.null2String(params.get(RequestAuthenticationConstant.AUTHORITY_STRING)) + "&authSignatureStr=" + Util.null2String(params.get(RequestAuthenticationConstant.AUTHORITY_SIGNATURESTRING));
        }

        workflowid = Util.getIntValue(Util.null2String(params.get("workflowid")), 0);
        nodeid = Util.getIntValue(Util.null2String(params.get("nodeid")), 0);
        isworkflowhtmldoc = "1".equals(Util.null2String(attrSignatureUtil.getAttribute("isworkflowhtmldoc" + requestid)));
        desrequestid = Util.getIntValue(Util.null2String(attrSignatureUtil.getAttribute("desrequestid")));
        isrequest = Util.getIntValue(Util.null2String(attrSignatureUtil.getAttribute("isrequest")));
        isprint = "1".equals(Util.null2String(params.get("isprint")));
        try {
            ResourceComInfo = new ResourceComInfo();
            DepartmentComInfo = new DepartmentComInfo();
            CustomerInfoComInfo = new CustomerInfoComInfo();
            apidatas = getRequestLogData();
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("error", "1");
        }
        return apidatas;
    }

    public Map<String, Object> getRequestLogData() throws Exception {
        RecordSet recordSet = new RecordSet();
        WorkflowAllComInfo wfComInfo = new WorkflowAllComInfo();
        boolean isFromWfForm = "1".equals(params.get("isFromWfForm"));
        long start = System.currentTimeMillis();
        int userid = user.getUID();
        boolean isdebug = (userid == 8 || userid == 80 || userid == 1215 || userid == 1348 || userid == 3724 || userid == 4548);
        if (isdebug) {
            System.out.println("requestlog-121-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        start = System.currentTimeMillis();
        Map<String, Object> resultDatas = new HashMap<String, Object>();

        boolean issplitload = Util.null2String(params.get("loadmethod")).equals("split");    //是否分页加载

        if (isdebug) {
            System.out.println("requestlog-122-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        start = System.currentTimeMillis();
        boolean loadbyuser = Boolean.parseBoolean(Util.null2String(params.get("loadbyuser")));
        String viewLogIds = Util.null2String(params.get("viewLogIds"));
        int creatorNodeId = Util.getIntValue(Util.null2String(params.get("creatorNodeId")));
        String isHideInput = Util.null2String(params.get("isHideInput"));

        // 是否流程督办
        int urger = Util.getIntValue(Util.null2String(attrSignatureUtil.getAttribute("urger")));
        // 是否流程干预
        int isintervenor = Util.getIntValue(Util.null2String(attrSignatureUtil.getAttribute("isintervenor")));

        // 转发引用权限
        int forward = Util.getIntValue(Util.null2String(params.get("forward")), 0);
        int submit = Util.getIntValue(Util.null2String(params.get("submit")), 0);

        // 页面是否有表单签章，有的话，取消引用按钮
        String isFormSignature = Util.null2String(params.get("isFormSignature"));
        boolean isFromMobile = "1".equals(Util.null2String(params.get("isFromMobile")));

        String pgflag = Util.null2String(params.get("pgnumber"));
        String maxrequestlogid = Util.null2String(params.get("maxrequestlogid"));
        int wfsignlddtcnt = Util.getIntValue(Util.null2String(params.get("wfsignlddtcnt")), 0);
        String orderbytype = Util.null2String(params.get("orderbytype"));
        boolean isOldWf = "true".equals(Util.null2String(params.get("isOldWf")));
        boolean isshowsrc = "1".equals(Util.null2String(wfComInfo.getShowSrc(String.valueOf(workflowid))));
		boolean isOpenCommunication = false;

        recordSet.executeQuery("select orderbytype, isOpenCommunication from workflow_base where id = ?",workflowid);
        if(recordSet.next()){
            orderbytype = Util.null2String(recordSet.getString(1));
			isOpenCommunication = recordSet.getInt(2) == 1;
        }
        if (loadbyuser) {
            recordSet.executeSql("SELECT nodeid FROM workflow_currentoperator WHERE requestid=" + requestid + " AND userid=" + user.getUID() + " ORDER BY receivedate desc,receivetime DESC");
            if (recordSet.next()) {
                String viewNodeId = recordSet.getString("nodeid");
                recordSet.executeSql("SELECT viewnodeids FROM workflow_flownode WHERE workflowid=" + workflowid + " AND nodeid=" + viewNodeId);
                String viewnodeids = "-1";
                if (recordSet.next()) {
                    viewnodeids = recordSet.getString("viewnodeids");
                }
                if ("-1".equals(viewnodeids)) {// 全部查看
                    recordSet.executeSql("SELECT nodeid FROM workflow_flownode WHERE workflowid= " + workflowid + " AND EXISTS(SELECT 1 FROM workflow_nodebase WHERE id=workflow_flownode.nodeid AND (requestid IS NULL OR requestid=" + requestid + "))");
                    while (recordSet.next()) {
                        viewLogIds += "," + recordSet.getString("nodeid");
                    }
                } else if (viewnodeids == null || "".equals(viewnodeids)) {// 全部不能查看
                } else {// 查看部分
                    viewLogIds += "," + viewnodeids;
                }
            }
        }

        int pgnumber = Util.getIntValue(pgflag);
        String orderby = "desc";
        if ("2".equals(orderbytype)) {
            orderby = "asc";
        }

        WFLinkInfo wfLinkInfo = new WFLinkInfo();
        wfLinkInfo.setRequest(request);
        wfLinkInfo.setIsprint(isprint);
        ArrayList log_loglist = null;
        // 获取高级查询的条件

        String sqlwhere = Util.null2String(params.get("sqlWhere"));
        if(!"".equals(sqlwhere)) writeLog("requestid:"+requestid+",userid:"+userid+",sqlwhere:"+sqlwhere);
        if ("".equals(source)){
            sqlwhere += wfLinkInfo.getRequestLogSearchConditionStr();
        }

        if (isdebug) {
            System.out.println("requestlog-123-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        // 节点签字意见权限控制
        RequestRemarkRight remarkRight = new RequestRemarkRight();
        String sqlcondition = remarkRight.getRightCondition(requestid, workflowid, user.getUID());
        sqlcondition += RequestLogBiz.getCustomSourceCondition(source,params);//添加source自定义条件
        sqlwhere += sqlcondition;

        if (isdebug) {
            System.out.println("requestlog-124-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }

        StringBuffer sbfmaxrequestlogid = new StringBuffer(maxrequestlogid);
        //分页加载重新计算当前页最大logid
        if (issplitload) {
            //sbfmaxrequestlogid = wfLinkInfo.getMaxLogid(requestid, workflowid, viewLogIds, orderby, wfsignlddtcnt, pgnumber, sqlwhere);
        }

        if (isdebug) {
            System.out.println("requestlog-125-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        if (pgflag == null || pgflag.equals("")) {
            log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, orderby, sqlcondition);
        } else {
            //log_loglist = wfLinkInfo.getRequestLog(requestid, workflowid, viewLogIds, orderby, wfsignlddtcnt, sbfmaxrequestlogid, sqlwhere);
            log_loglist = RequestLogBiz.getRequestLog(requestid,workflowid,viewLogIds,orderby,wfsignlddtcnt,pgnumber,sqlwhere,user.getLanguage());
            if(RequestLogBiz.isEndLog(requestid,workflowid,viewLogIds,orderby,wfsignlddtcnt,pgnumber,sqlwhere)){///判断此次加载是否是最后一页
                resultDatas.put("isEnd", true);
            }
        }

        resultDatas.put("maxrequestlogid", sbfmaxrequestlogid.toString());

        if (isdebug) {
            System.out.println("requestlog-126-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }

        int tempRequestLogId = 0;
        int tempImageFileId = 0;

        int languageidfromrequest = user.getLanguage();
        RecordSet recordSetlog3 = new RecordSet();
        WorkflowRequestComInfo wfrequestcominfo = new WorkflowRequestComInfo();
        DocImageManager DocImageManager = new DocImageManager();
        SecCategoryComInfo SecCategoryComInfo1 = new SecCategoryComInfo();
        RequestLogOperateName RequestLogOperateName = new RequestLogOperateName();
        String initUser = "";
        List<Map<String, Object>> loglistnew = new ArrayList<Map<String, Object>>();

        //签字意见相关流程
        String signrequestids = "";
        if (isdebug) {
            System.out.println("requestlog-127-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        start = System.currentTimeMillis();

        //二次认证，数据保护的验证
        Map<String, Object> checkMap = SecondAuthBiz.getProtectedLogs(requestid);
        Map<String, String> logIdMap = (HashMap<String, String>) checkMap.get("logIdMap");
        int checkLogId = Util.getIntValue(Util.null2String(checkMap.get("logId")), -1);
        checkMap.remove("logIdMap");
        RequestSecondAuthService requestSecondAuthService = com.engine.common.util.ServiceUtil.getService(RequestSecondAuthServiceImpl.class, user);
        //批量获取契约锁认证的信息
        Map<String, Object> qysSignInfoMap = SecondAuthBiz.getMultiQYSSignInfo(requestid);

        DateTransformer dft = new DateTransformer();
        UnifiedConversionInterface uci = new UnifiedConversionInterface();
		QysSignatureCominfo signatureCominfo = new QysSignatureCominfo();

        int tempnodeid  = FreeNodeBiz.getExtendNodeId(requestid,nodeid);
        Map<String, String> operateNameMap = getOperateMenuName(tempnodeid, user.getLanguage());
        String forwardMenuName = operateNameMap.get("forwardName");

        for (int i = 0; i < log_loglist.size(); i++) {
            Hashtable htlog = (Hashtable) log_loglist.get(i);
            Map<String, Object> logmap = new HashMap<String, Object>();
            int log_nodeid = Util.getIntValue((String) htlog.get("nodeid"), 0);
            int log_destnodeid = Util.getIntValue((String) htlog.get("destnodeid"), 0);
            int log_nodeattribute = Util.getIntValue((String) htlog.get("nodeattribute"), 0);
            String log_nodename = Util.null2String((String) htlog.get("nodename"));
            String log_remark = RequestFormBiz.manageCssPollute(Util.null2String((String) htlog.get("remark")));
            String log_operator = Util.null2String((String) htlog.get("operator"));
            String log_operatedate = Util.null2String((String) htlog.get("operatedate"));
            String log_operatetime = Util.null2String((String) htlog.get("operatetime"));
            String isRobotNode = Util.null2String((String) htlog.get("isRobotNode"));
            if(uci.getTimeZoneStatus()) {
                //开启多时区
                String[] tempoperatetime = dft.getLocaleDateAndTime(log_operatedate,log_operatetime);
                log_operatedate = tempoperatetime[0];
                log_operatetime = tempoperatetime[1];
            }

            String log_logtype = Util.null2String((String) htlog.get("logtype"));
            String log_receivedPersons = Util.null2String((String) htlog.get("receivedPersons"));
            String log_receivedPersonIds = Util.null2String((String) htlog.get("receivedPersonids"));
            tempRequestLogId = Util.getIntValue((String) htlog.get("logid"), 0);
            String log_annexdocids = Util.null2String((String) htlog.get("annexdocids"));
            String log_signdocids = Util.null2String((String) htlog.get("signdocids"));
            String log_signworkflowids = Util.null2String((String) htlog.get("signworkflowids"));
            String tmpLogId = Util.null2String(htlog.get("tmpLogId"));
            String remarkLocation = Util.null2String(htlog.get("remarkLocation"));
            String ismobile = Util.null2String(htlog.get("isMobile"));

            String remarkHtml = Util.null2String((String) htlog.get("remarkHtml"));
            SignSource signSource = "t".equals(log_logtype) ? null : SignSource.getSignSource(ismobile);
            String mobileSuffix  = "";
            if(signSource != null && (isshowsrc || signSource == SignSource.AUTO_APPROVE || signSource == SignSource.AUTO_SUBMIT)) {
                remarkHtml += SignSource.getSignSourceHtml(signSource,user.getLanguage());
                //不显示意见来源，处理历史数据
            } else if (!isshowsrc) {
                remarkHtml = RequestLogBiz.removeRemarkSource(remarkHtml);
            }else if(isshowsrc){
                String remarktemp = remarkHtml;
                remarkHtml = RequestLogBiz.removeRemarkSource(remarktemp);
                int index = remarktemp.indexOf("<span style='font-size:11px;color:#666;'>来自微信企业号");
                if (index > 0) {
                    int index2 = remarktemp.indexOf("</span>", index);
                    remarkHtml += "<br>" + remarktemp.substring(index, index2);
                }
            }

            logmap.put("forwardMenuName", forwardMenuName);

            logmap.put("remarkLocation",remarkLocation);

            String log_remarkHtml = RequestFormBiz.manageCssPollute(remarkHtml);

            String log_iframeId = Util.null2String((String) htlog.get("iframeId"));

            int requestLogId = Util.getIntValue(Util.null2String(htlog.get("id")), 0);

            String log_operatortype = Util.null2String((String) htlog.get("operatortype"));

            //验证数据
            //if (!isprint) {
                logmap.put("isProtected", "0");
                logmap.put("checkSuccess", "-1");
                if (requestLogId > 0) {
                    if (logIdMap.containsKey(String.valueOf(tmpLogId))) {       //有契约锁数据保护
                        int protectType = Util.getIntValue(Util.null2String(logIdMap.get(tmpLogId)), 0);
                        logmap.put("isProtected", "1");
                        logmap.put("protectType", protectType);

                        if (protectType == SecondAuthType.QYS.getId()) {      //契约锁数据保护
                            //add by fmj 2019-08-27 因为契约锁数据保护，也会先进行契约锁认证，因此此处先取认证时选择的印章，
                            //String qysSignatureId = SecondAuthBiz.getQYSSignatureId(Util.getIntValue(tmpLogId, 0));
                            String qysSignatureId = "";
                            Map<String, Object> certDetails = new HashMap<String, Object>();
                            if (qysSignInfoMap.containsKey(tmpLogId)) {
                                Map<String, Object> signInfoMap = (Map<String, Object>) qysSignInfoMap.get(tmpLogId);
                                if (signInfoMap != null) {
                                    qysSignatureId = Util.null2String(signInfoMap.get("signatureId"));
                                    certDetails = (Map<String, Object>) signInfoMap.get("certDetails");
                                }
                            }
                            int signatureId = Util.getIntValue(qysSignatureId, 0);

                            //没有认证时选择的印章，再取从契约锁同步过来的个人签名
                            if (signatureId <= 0) {
                                qysSignatureId = signatureCominfo.getSignatureid(log_operator);
                                signatureId = Util.getIntValue(qysSignatureId, 0);
                            }
                            if (signatureId > 0) {
                                String signIdCode = DocDownloadCheckUtil.EncodeFileid(signatureId + "",user);
                                logmap.put("qys_signature_id", signIdCode);

                                //添加印章的尺寸
//                                Map<String, Object> certDetails = SecondAuthBiz.getCertDetails(Util.getIntValue(tmpLogId, 0));
                                int qyswidth = (int)Util.getDoubleValue(Util.null2String(certDetails.get("qyswidth")),0);
                                int qysheight = (int)Util.getDoubleValue(Util.null2String(certDetails.get("qysheight")),0);
                                logmap.put("qyswidth",qyswidth);
                                logmap.put("qysheight",qysheight);
                            }
                        }

                        //数据保护默认所有的都是验证通过的，只对最后一条签字意见做特殊处理，需要验证数据有效性
                        logmap.put("checkSuccess", 1);
                        logmap.put("clickCheck", 0);
                    } else {     //没有契约锁数据保护
                        //String qysSignatureId = SecondAuthBiz.getQYSSignatureId(Util.getIntValue(tmpLogId, 0));
                        String qysSignatureId = "";
                        Map<String, Object> certDetails = new HashMap<String, Object>();
                        if (qysSignInfoMap.containsKey(tmpLogId)) {
                            Map<String, Object> signInfoMap = (Map<String, Object>) qysSignInfoMap.get(tmpLogId);
                            if (signInfoMap != null) {
                                qysSignatureId = Util.null2String(signInfoMap.get("signatureId"));
                                certDetails = (Map<String, Object>) signInfoMap.get("certDetails");
                            }
                        }

                        int signatureId = Util.getIntValue(qysSignatureId, 0);
                        if (signatureId > 0) {
                            String signIdCode = DocDownloadCheckUtil.EncodeFileid(signatureId + "",user);
                            logmap.put("qys_signature_id", signIdCode);
                            //添加印章的尺寸
                            //Map<String, Object> certDetails = SecondAuthBiz.getCertDetails(Util.getIntValue(tmpLogId, 0));
                            int qyswidth = (int)Util.getDoubleValue(Util.null2String(certDetails.get("qyswidth")),0);
                            int qysheight = (int)Util.getDoubleValue(Util.null2String(certDetails.get("qysheight")),0);
                            logmap.put("qyswidth",qyswidth);
                            logmap.put("qysheight",qysheight);
                        }
                    }

                    if (requestLogId == checkLogId) {   //最后一条签字意见，验证数据保护
                        Map<String, Object> checkResult = requestSecondAuthService.checkProtectDatas(checkMap);
                        String checkSuccess = Util.null2String(checkResult.get("success"));
                        logmap.put("checkSuccess", checkSuccess);
                        logmap.put("clickCheck", 1);
                    }
                }
           // }

            if (pgflag == null || pgflag.equals("")) {
                if (log_loglist.size() > 10) {
                    if (i < 10) {
                        continue;
                    }
                }
            }

            tempImageFileId = 0;
            if (tempRequestLogId > 0) {
                recordSet.executeSql("select imageFileId from Workflow_FormSignRemark where requestLogId=" + tempRequestLogId);
                if (recordSet.next()) {
                    tempImageFileId = Util.getIntValue(recordSet.getString("imageFileId"), 0);
                }
            }
            logmap.put("logid", Util.null2String((String) htlog.get("id")));
			
			//是否有相关交流引用
            if (isOpenCommunication) {
                logmap.put("hasCommunicationQuote", WorkflowCommunicationBiz.requestLogQuoteCheck(Util.getIntValue(Util.null2String(logmap.get("logid")))));
            }

            String img_path = "0".equals(log_operatortype) ? ResourceComInfo.getMessagerUrls(log_operator) : "/messager/images/icon_m_wev8.jpg";
            img_path = RobotNodeBiz.operatortype.equals(log_operatortype) ? "/messager/images/robot.png" : img_path;
            // 人员头像
            logmap.put("img_path", img_path);

            int showimg = Util.getIntValue(recordSet.getPropValue("WFSignatureImg", "showimg"), 0);
            int signnaturImgHeight = Util.getIntValue(recordSet.getPropValue("WFSignatureImg", "imgheight"));
            recordSet.execute("select * from DocSignature  where hrmresid=" + log_operator + " and sealtype = 1 order by markid");
            String userimg = "";
            // 表单签章
            if (showimg == 1 && recordSet.next() && true && "0".equals(log_operatortype)) {
                String markpath = Util.null2String(recordSet.getString("markpath"));
                if (!markpath.equals("")) {
					OdocFileUtil odocfileutil = new OdocFileUtil();
					String useridrandom = odocfileutil.changeParamToBase64Str(Util.getIntValue(log_operator,-1)+"");
                    userimg = "/weaver/weaver.file.ImgFileDownload?userid=" + useridrandom+"&sealType=1";
                }
            }
            logmap.put("userimg", userimg);
            logmap.put("signnaturImgHeight", signnaturImgHeight);




            this.loadOperatorInfo(isOldWf, htlog, creatorNodeId, recordSetlog3, logmap);

            // 签字意见内容
            if (!log_logtype.equals("t")) {
                // 表单签章
                if (tempRequestLogId > 0 && tempImageFileId > 0) {
                    log_remarkHtml += "<img src=\"/weaver/weaver.file.FileDownload?fileid="+tempImageFileId+"\"></img>";
                } else {
                    Pattern pattern0 = Pattern.compile("(\\/workflow\\/request\\/ViewRequest(ForwardSPA)?\\.jsp\\?)");
                    Matcher m0 = pattern0.matcher(log_remarkHtml);
                    if(m0.find()) {
                        log_remarkHtml = m0.replaceAll("/workflow/request/ViewRequestForwardSPA.jsp?f_weaver_belongto_userid=" + f_weaver_belongto_userid + authSignatureInfo + "&desrequestid=" + requestid + "&");
                    }
                    Pattern pattern1 = Pattern.compile("(\\/docs\\/docs\\/DocDsp.jsp\\?)");
                    Matcher m1 = pattern1.matcher(log_remarkHtml);
                    if (m1.find()) {
                        log_remarkHtml = m1.replaceAll(ServiceUtil.docViewUrl + "?f_weaver_belongto_userid=" + f_weaver_belongto_userid + authSignatureInfo + "&desrequestid=" + requestid + "&");
                    }
                    // 流程签字意见内容中附件
                    if(log_remarkHtml.indexOf("desrequestid=0")>-1)
                    log_remarkHtml = log_remarkHtml.replace("desrequestid=0", "desrequestid=" + desrequestid);
                    if(log_remarkHtml.indexOf("requestid=-1")>-1)
                    log_remarkHtml = log_remarkHtml.replace("requestid=-1", "requestid=" + requestid);

//                    if (log_remarkHtml.indexOf("<img") > -1 && !isFromMobile) {
//                        String begin_logRemark = "";
//                        String new_logRemark = "";
//                        String end_logRemark = "";
//                        String cycleString = log_remarkHtml;
//                        int f = 0;
//                        while (cycleString.indexOf("<img") > -1) {
//                            f++;
//                            int b = cycleString.indexOf("<img");
//                            begin_logRemark = cycleString.substring(0, b);
//                            new_logRemark += begin_logRemark;
//                            cycleString = cycleString.substring(b);
//                            String imgString = "";
//                            int e = cycleString.indexOf("/>");
//                            imgString = cycleString.substring(0, e);
//                            if (isworkflowhtmldoc) {
//                                new_logRemark += "<a>" + imgString + " onload=\"image_resize(this,'" + log_iframeId + "');\" onresize=\"image_resize(this,'" + log_iframeId + "');\" /> </a>";
//                            } else {
//                                new_logRemark += "<div class=\"small_pic\"><a pichref=\"pic_one" + f + "\">" + imgString
//                                        + " style=\"max-width:100%;\" "+(isprint ? "onload" : "original-onload")+"=\"image_resize(this,'" + log_iframeId + "');\" "+(isprint ? "onresize" : "original-onresize")+"=\"image_resize(this,'" + log_iframeId + "');\" /> </a></div><div id=\"pic_one" + f + "\" style=\"display:none;\">" + imgString + " style=\"max-width:100%;\" class=\"maxImg\" /></div>";
//                            }
//                            cycleString = cycleString.substring(e + 2);
//                            end_logRemark = cycleString;
//                        }
//                        new_logRemark += end_logRemark;
//                        log_remarkHtml = new_logRemark;
//                    }

                    if(!isprint && isFromWfForm)
                        log_remarkHtml= RequestFormBiz.manageImgLazyLoad(log_remarkHtml);	//图片懒加载处理

                    if (isprint && log_remark.indexOf("<img") > -1) { // 打印使用的是log_remark，也需要处理img
                        // /////////
                        String begin_logRemark = "";
                        String new_logRemark = "";
                        String end_logRemark = "";
                        String cycleString = log_remark;
                        int f = 0;
                        while (cycleString.indexOf("<img") > -1) {
                            f++;
                            int b = cycleString.indexOf("<img");
                            begin_logRemark = cycleString.substring(0, b);
                            new_logRemark += begin_logRemark;
                            cycleString = cycleString.substring(b);
                            String imgString = "";
                            int e = cycleString.indexOf("/>");
                            imgString = cycleString.substring(0, e);
                            new_logRemark += "<div class=\"small_pic\">" + imgString + " onload=\"image_resize(this,'" + log_iframeId + "');\" onresize=\"image_resize(this,'" + log_iframeId + "');\" /></div><div id=\"pic_one" + f + "\" style=\"display:none;\">" + imgString
                                    + " class=\"maxImg\" /></div>";
                            cycleString = cycleString.substring(e + 2);
                            end_logRemark = cycleString;
                        }
                        new_logRemark += end_logRemark;
                        log_remark = new_logRemark;
                    }

                    String tempremark = log_remark;
                    tempremark = Util.StringReplace(tempremark, "&lt;br&gt;", "<br>");
                    if (!"".equals(tempremark) && isprint) {
                        tempremark += "<br>";
                    }
                    logmap.put("tempremark", tempremark);
                    logmap.put("pgflag", Util.null2String(pgflag));

                }
            }
            try {
                String appendData = log_remarkHtml;
                if(appendData.indexOf("handwritten_xzl")>-1){
                    int start1 = appendData.indexOf("handwritten_xzl")+21;
                    String tempStr = appendData.substring(start1);
                    int end = tempStr.indexOf("src")-2;
                    String fileId=  tempStr.substring(0,end);

                    String new_img="";
                    String attachmentidAes = DocDownloadCheckUtil.checkPermission(String.valueOf(fileId), null);
                    new_img += "<BR/><img class=\'handwritten_xzl\' style=\'width:50%\' name=\"handWrittenSign\" src=\"/weaver/weaver.file.FileDownload?fileid=" + attachmentidAes + "\" />";

                    String begin_logRemark = "";
                    String new_logRemark = "";
                    String end_logRemark = "";
                    String cycleString = appendData;
                    if (cycleString.indexOf("<img class=\"handwritten_xzl\"") > -1) {
                        int b = cycleString.indexOf("<img class=\"handwritten_xzl\"");
                        begin_logRemark = cycleString.substring(0, b);
                        new_logRemark += begin_logRemark;
                        cycleString = cycleString.substring(b);
                        int e = cycleString.indexOf("/>");
                        new_logRemark += new_img;
                        cycleString = cycleString.substring(e + 2);
                        end_logRemark = cycleString;
                    }
                    new_logRemark += end_logRemark;
                    log_remarkHtml = new_logRemark;
                }
            }catch(Exception e){
                e.printStackTrace();
            }
            logmap.put("log_remarkHtml", ServiceUtil.convertChar(log_remarkHtml));

            if(isrequest==-1){
                isrequest = Util.getIntValue(Util.null2String(params.get("isrequest")))==-1?1:Util.getIntValue(Util.null2String(params.get("isrequest")));
            }

            // 相关文件
            if (!log_annexdocids.equals("") || !log_signdocids.equals("") || !log_signworkflowids.equals("")) {
                // 相关文档
                if (!log_signdocids.equals("")) {
                    recordSetlog3.executeSql("select id,docsubject,accessorycount,SecCategory from docdetail where id in(" + log_signdocids + ") order by id asc");
                    List<Map<String, String>> signdocs = new ArrayList<Map<String, String>>();
                    while (recordSetlog3.next()) {
                        Map<String, String> map = new HashMap<String, String>();
                        String showid = Util.null2String(recordSetlog3.getString(1));
                        String tempshowname = Util.toScreen(recordSetlog3.getString(2), languageidfromrequest);

                        map.put("showid", showid);
                        map.put("authStr", authStr);
                        map.put("authSignatureStr", authSignatureStr);
                        map.put("tempshowname", tempshowname);
                        map.put("filelink", ServiceUtil.docViewUrl + "?f_weaver_belongto_userid=" + user.getUID() + "&f_weaver_belongto_usertype=" + f_weaver_belongto_usertype + "&id=" + showid + "&isrequest="+isrequest+"&requestid=" + requestid + authSignatureInfo);

                        signdocs.add(map);
                    }

                    logmap.put("signdocs", signdocs);
                }

                int tempnum = Util.getIntValue(String.valueOf(attrSignatureUtil.getAttribute("slinkwfnum")));
//                if(tempnum <= 0){
//                    tempnum = Util.getIntValue(String.valueOf(session.getAttribute("slinkwfnum")));
//                }
                // 相关流程
                if (!log_signworkflowids.equals("")) {
                    List<Map<String, Object>> signwfs = new ArrayList<Map<String, Object>>();
                    ArrayList<String> tempwflists = Util.TokenizerString(log_signworkflowids, ",");
                    for (int k = 0; k < tempwflists.size(); k++) {
                        tempnum++;
                        //session.setAttribute("resrequestid" + tempnum, "" + tempwflists.get(k));
                        Map<String, Object> map = new HashMap<String, Object>();
                        map.put("isrequest", "1");
                        map.put("requestid", tempwflists.get(k));
                        //map.put("wflinkno", tempnum + "");
                        map.put("desrequestid", requestid);
                        map.put("authSignatureInfo",authSignatureInfo);
                        map.put("authStr",authStr);
                        map.put("authSignatureStr",authSignatureStr);
                        map.put("f_weaver_belongto_userid", f_weaver_belongto_userid);
                        map.put("f_weaver_belongto_usertype", f_weaver_belongto_usertype);
                        map.put("title", wfrequestcominfo.getRequestName((String) tempwflists.get(k)));
                        signwfs.add(map);
                        signrequestids += tempwflists.get(k) + ",";
                    }

                    logmap.put("signwfs", signwfs);
                }

                //session.setAttribute("slinkwfnum", "" + tempnum);
                //session.setAttribute("haslinkworkflow", "1");
                attrSignatureUtil.setAttribute("haslinkworkflow", "1");

                // 相关附件
                if (!log_annexdocids.equals("")) {
                    recordSetlog3.executeSql("select id,docsubject,accessorycount,SecCategory from docdetail where id in(" + log_annexdocids + ") order by id asc");
                    List<Map<String, Object>> annexdocs = new ArrayList<Map<String, Object>>();
                    while (recordSetlog3.next()) {

                        String showid = Util.null2String(recordSetlog3.getString(1));
                        String tempshowname = Util.toScreen(recordSetlog3.getString(2), languageidfromrequest);
                        int accessoryCount = recordSetlog3.getInt(3);
                        String SecCategory = Util.null2String(recordSetlog3.getString(4));
                        DocImageManager.resetParameter();
                        DocImageManager.setDocid(Util.getIntValue(showid));
                        DocImageManager.selectDocImageInfo();

                        String docImagefilename = "";
                        String fileExtendName = "";
                        String docImagefileid = "";
                        int versionId = 0;
                        long docImagefileSize = 0;
                        if (DocImageManager.next()) {
                            // DocImageManager会得到doc第一个附件的最新版本

                            docImagefilename = DocImageManager.getImagefilename();
                            fileExtendName = docImagefilename.substring(docImagefilename.lastIndexOf(".") + 1).toLowerCase();
                            docImagefileid = DocImageManager.getImagefileid();
                            docImagefileSize = DocImageManager.getImageFileSize(Util.getIntValue(docImagefileid));
                            versionId = DocImageManager.getVersionId();
                        }
                        if (accessoryCount > 1) {
                            fileExtendName = "htm";
                        }
                        //String imgSrc = AttachFileUtil.getImgStrbyExtendName(fileExtendName, 16);
                        boolean nodownload = SecCategoryComInfo1.getNoDownload(SecCategory).equals("1") ? true : false;
                        String filelink = "";

                        //打开文档判断是否在线预览，文档处已经做了全部的处理。所以这边直接走else逻辑
                        if (false && accessoryCount == 1 && (fileExtendName.equalsIgnoreCase("xls") || fileExtendName.equalsIgnoreCase("doc") || fileExtendName.equalsIgnoreCase("xlsx") || fileExtendName.equalsIgnoreCase("docx") || fileExtendName.equalsIgnoreCase("pdf"))) {
                            filelink = ServiceUtil.docViewUrl + "?f_weaver_belongto_userid=" + user.getUID() + "&f_weaver_belongto_usertype=" + f_weaver_belongto_usertype + "&id=" + showid + "&imagefileId=" + docImagefileid + "&isFromAccessory=true&isrequest="+isrequest+"&requestid=" + requestid + "&desrequestid=" + desrequestid + authSignatureInfo;
                        } else {
                            filelink = ServiceUtil.docViewUrl + "?f_weaver_belongto_userid=" + user.getUID() + "&f_weaver_belongto_usertype=" + f_weaver_belongto_usertype + "&id=" + showid + "&isrequest="+isrequest+"&requestid=" + requestid + "&desrequestid=" + desrequestid + authSignatureInfo;
                        }
                        String downloadlink = "";
                        if (accessoryCount == 1 && !isprint && ((!fileExtendName.equalsIgnoreCase("xls") && !fileExtendName.equalsIgnoreCase("doc")) || !nodownload)) {
                            downloadlink =  weaver.general.GCONST.getContextPath()+"/weaver/weaver.file.FileDownload?fileid=" + docImagefileid + "&download=1&requestid=" + requestid + "&desrequestid=" + desrequestid + authSignatureInfo;
                        }
                        Map<String, Object> map = new HashMap<String, Object>();
                        map.put("showid", showid);                       //附件ID
                        map.put("docImagefilename", docImagefilename); //附件名称
                        map.put("fileExtendName", fileExtendName);       //附件后缀名
                        map.put("docImagefileid", docImagefileid);
                        map.put("versionId", versionId);
                        map.put("docImagefileSize", docImagefileSize);
                        map.put("nodownload", nodownload);
                        map.put("tempshowname", tempshowname);
                        map.put("filelink", filelink);
                        map.put("downloadlink", downloadlink);
                        map.put("authStr",authStr);
                        map.put("authSignatureStr",authSignatureStr);
                        boolean docright = true;
                        if("1".equals(new WorkflowConfigComInfo().getValue("file_download_use_docright"))){
                            DocViewPermission docViewPermission = new DocViewPermission();
                            docright = docViewPermission.getShareLevel(Util.getIntValue(showid), user, false).get(DocViewPermission.DOWNLOAD);
                            new BaseBean().writeLog("流程附件下载权限走知识组权限:docright："+docright+";showid:"+showid);
                        }
                        map.put("showdownload", docright && (!Strings.isNullOrEmpty(downloadlink)) );
                        annexdocs.add(map);
                    }
                    //需要按照存放顺序显示，存放顺序即log_annexdocids的顺序
                    String [] idssort = log_annexdocids.split(",");
                    List<Map<String, Object>> annexdocssort = new ArrayList<Map<String, Object>>();
                    for(String sort: idssort) {
                        for(int si = 0;si<annexdocs.size();si++){
                            if(sort.trim().equals(annexdocs.get(si).get("showid").toString().trim())){
                                annexdocssort.add(annexdocs.get(si));
                                break;
                            }
                        }
                    }
                    if(annexdocs.size() != annexdocssort.size()){
                        annexdocssort = annexdocs;//防止循环导致数据丢失
                    }
                    logmap.put("annexdocs", annexdocssort);
                }
            }

            // 接收人 默认显示10个接收人
            int showCount = isFromMobile ? 40: 20;
            String[] initUsers = null;
            // 流程退回 || 流程分叉节点提交
            if("3".equals(log_logtype) || (1 == log_nodeattribute && (log_logtype.equals("0") || log_logtype.equals("2") || log_logtype.equals("3") || log_logtype.equals("t")))) {
            //if (((log_nodeattribute != 2) && (log_logtype.equals("0") || log_logtype.equals("2") || log_logtype.equals("3") || log_logtype.equals("t")))) {// 分叉起始或者主干退回到分叉
                String[] _log_receivedPersons = wfLinkInfo.getForkStartReceivers(requestid, tempRequestLogId, log_nodeid, log_operatedate, log_operatetime, log_logtype, log_destnodeid);
                log_receivedPersons = _log_receivedPersons[0];
            }
            if (log_receivedPersons.length() > 0 && log_receivedPersons.trim().endsWith(",")) {
                log_receivedPersons = log_receivedPersons.substring(0, log_receivedPersons.length() - 1);
            }

            initUsers = log_receivedPersons.split(",");
            initUser = "";
            if (initUsers.length > showCount) {
                for (int j = 0; j < showCount; j++) {
                    initUser += "," + initUsers[j];
                }
                if (initUser.length() > 1) {
                    initUser = initUser.substring(1);
                }
            } else {
                initUser = log_receivedPersons;
            }

            loadMobileInfo(htlog,logmap);
            // 如果是打印页面，则不隐藏接收人

            logmap.put("receiveUser", ServiceUtil.convertChar(initUser));
            logmap.put("receiveUserCount", Util.splitString2List(log_receivedPersonIds,",").size());

            //判断是否需要显示意见接收人栏的加载更多按钮
            boolean showMoreReceiveBtn = log_receivedPersonIds.split(",").length > log_receivedPersons.split(",").length ? true : false;
            logmap.put("showMoreReceiveBtn", showMoreReceiveBtn);

            // 操作时间
            logmap.put("log_operatedate", Util.toScreen(log_operatedate, languageidfromrequest));
            logmap.put("log_operatetime", Util.toScreen(log_operatetime, languageidfromrequest));


            // 节点信息
            logmap.put("log_nodename", Util.toScreen(log_nodename, languageidfromrequest));
            String logtype = log_logtype;
            String operationname = "";
            if("1".equals(isRobotNode)){
                operationname = Util.formatMultiLang(new RobotNodeServiceBiz().getRobotNodeSet(Util.getIntValue(log_nodeid)).getOperateTypeName(), languageidfromrequest + "");
            }
            if("".equals(operationname)){
                operationname = RequestLogOperateName.getOperateName("" + workflowid, "" + requestid, "" + log_nodeid, logtype, log_operator, languageidfromrequest,log_operatedate,log_operatetime);
            }

            logmap.put("operationname", operationname);

            // 引用按钮
            boolean isReference = (!isHideInput.equals("1") && ((isintervenor == 1 || urger == 1 || submit == 1) && !isFormSignature.equals("1")) && !log_logtype.equals("t") && (log_remarkHtml != null && !"".equals(log_remarkHtml.trim())));

            logmap.put("isReference", isReference);

            logmap.put("displaytype", log_operatortype);

            // 转发
            logmap.put("forward", forward);
            logmap.put("logtype",log_logtype);

            loglistnew.add(logmap);
        }
        if (isdebug) {
            System.out.println("requestlog-128-requestid-" + requestid + "-userid-" + userid + "-" + (System.currentTimeMillis() - start));
            start = System.currentTimeMillis();
        }
        resultDatas.put("totalCount", RequestLogBiz.getRequestLogTotalCount(requestid, workflowid, viewLogIds, sqlwhere));

        //相关请求增加session信息
        //ServiceUtil.addRelatedWfSession(request, this.requestid, signrequestids);

        resultDatas.put("loglist", loglistnew);
        return resultDatas;
    }

    //支持手机端
    private void loadMobileInfo(Hashtable htlog,Map<String, Object> logmap){
        //设置手写签批
        String attenchmentID = Util.null2String(htlog.get("handwrittensignid"));
        new BaseBean().writeLog("handwrittensignid123:"+attenchmentID);
        List<DocAttachment> docAttachments = new ArrayList<>();
        String[] attenchmentids = attenchmentID.split(",");
        if(!"".equals(attenchmentID)) {
            for (int i = 0; i < attenchmentids.length; i++) {
                int attenchmentid = Util.getIntValue(attenchmentids[i]);
                if (attenchmentid > 0) {
                    String strData = WorkflowSpeechAppend.getAppend(attenchmentid);
                    logmap.put("handWrittenSign", "data:image/png;base64," + strData);
                    //获取手写签章详细信息
                    DocAttachment docAttObj = WorkflowSpeechAppend.getAttachment(attenchmentid);
                    docAttachments.add(docAttObj);
                }
            }
        }
        logmap.put("handWrittenSignDoc", docAttachments);
        //设置语音附件
        int attenchmentID1 = Util.getIntValue(Util.null2String(htlog.get("speechattachmentid")));
        String speechAttachmente9 = Util.null2String(htlog.get("speechAttachmente9"));
        if(attenchmentID1 > 0){
            if(!"".equals(speechAttachmente9)) {
                speechAttachmente9 += "," + attenchmentID1;
            } else {
                speechAttachmente9 =  attenchmentID1 + "";
            }
        }
        List<String> speechAttachmetnDatas = new ArrayList <>();
        if(!"".equals(speechAttachmente9)) {
            String[] speechIds = Util.splitString(speechAttachmente9,",");
            for(String speechid : speechIds) {
                int _speechid = Util.getIntValue(speechid);
                if(_speechid > 0) {
                    DocAttachment attenchmentDoc = WorkflowSpeechAppend.getAttachment(_speechid);
                    String fileType = attenchmentDoc.getFiletype();
                    if(fileType.indexOf("/") >=0){
                        fileType = fileType.substring(fileType.indexOf("/") + 1);
                    }
                    speechAttachmetnDatas.add("data:audio/" + fileType + ";base64," + WorkflowSpeechAppend.getAppend(_speechid));
                }
            }
        }
        logmap.put("speechAttachmetnDatas",speechAttachmetnDatas);

        //电子签章
        String remark = Util.null2String(logmap.get("log_remarkHtml"));
        String eletriSignature = WorkflowSpeechAppend.getElectrSignatrue(remark);
        if (eletriSignature != null && !"".equals(eletriSignature)){
            Pattern pattern = Pattern.compile("/weaver/weaver\\.file\\.SignatureDownLoad\\?markId=\\d+");
            Matcher matcher = pattern.matcher(eletriSignature);
            if(matcher.find()){
                String tempurl = matcher.group();
                logmap.put("eletriSignature", tempurl);
            }else{
                writeLog(String.format("The eletriSignature URL of '%1$s' is null.", eletriSignature));
            }
        }
    }

    /**
     * 加载节点操作者信息
     *
     * @param isOldWf
     * @param htlog
     * @param creatorNodeId
     * @param recordSetlog3
     */
    private void loadOperatorInfo(boolean isOldWf, Hashtable htlog, int creatorNodeId, RecordSet recordSetlog3, Map<String, Object> logmap) {
        int languageidfromrequest = user.getLanguage();

        boolean isexsAgent = false;
        boolean isinneruser = true;
        String displayid = "";
        String displayname = "";
        String displaydepid = "";
        String displaydepname = "";
        String displaybyagentid = "";
        String displaybyagentname = "";

        String log_operatortype = Util.null2String((String) htlog.get("operatortype"));
        String log_operatorDept = Util.null2String((String) htlog.get("operatorDept"));
        String log_operator = Util.null2String((String) htlog.get("operator"));
        String log_agenttype = Util.null2String((String) htlog.get("agenttype"));
        String log_agentorbyagentid = Util.null2String((String) htlog.get("agentorbyagentid"));
        int log_nodeid = Util.getIntValue((String) htlog.get("nodeid"), 0);
        if (log_operatortype.equals("0") && !"0".equals(Util.null2String(log_operatorDept)) && !"".equals(Util.null2String(log_operatorDept))) {
            displaydepid = Util.toScreen(log_operatorDept, languageidfromrequest);
            OrganizationShowSetBiz orgShowBiz = new OrganizationShowSetBiz();
            displaydepname = Util.toScreen(orgShowBiz.getDepartmentShow("workflow", log_operatorDept), languageidfromrequest);
        }

        String robotNodeName = new RobotNodeServiceBiz().getRobotNodeSet(log_nodeid).getOperatorName();
        if (isOldWf) {
            if (log_operatortype.equals("0")) {
                if (isprint == false) {
                    displayid = log_operator;
                    displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                } else {
                    displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                }
            } else if (log_operatortype.equals("1")) {
                isinneruser = false;
                if (isprint == false) {
                    displayid = log_operator;
                    displayname = Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(log_operator), languageidfromrequest);
                } else {
                    displayname = Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(log_operator), languageidfromrequest);
                }
            } else if (log_operatortype.equals(RobotNodeBiz.operatortype)){
                if (isprint == false) {
                    displayid = log_operator;
                    displayname = Util.toScreen(robotNodeName, languageidfromrequest);
                } else {
                    displayname = Util.toScreen(robotNodeName, languageidfromrequest);
                }
            }else {
                displayname = SystemEnv.getHtmlLabelName(468, languageidfromrequest);
            }
        } else {
            if (log_operatortype.equals("0")) {
                if (isprint == false) {
                    if (!log_agenttype.equals("2")) {
                        displayid = log_operator;
                        displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                    } else if (log_agenttype.equals("2") || log_agenttype.equals("1")) {
                        isexsAgent = true;
                        displaybyagentid = log_agentorbyagentid;
                        displaybyagentname = Util.toScreen(ResourceComInfo.getLastname(log_agentorbyagentid), languageidfromrequest);
                        displayid = log_operator;
                        displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                    } else {
                    }
                } else {
                    if (!log_agenttype.equals("2")) {
						displayid = log_operator;
                        displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                    } else if (log_agenttype.equals("2")) {
                        isexsAgent = true;
						displayid = log_operator;
                        displaybyagentname = Util.toScreen(ResourceComInfo.getLastname(log_agentorbyagentid), languageidfromrequest);
                        displayname = Util.toScreen(ResourceComInfo.getLastname(log_operator), languageidfromrequest);
                    } else {
                    }
                }
            } else if (log_operatortype.equals("1")) {
                isinneruser = false;
                if (isprint == false) {
                    displayid = log_operator;
                    displayname = Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(log_operator), languageidfromrequest);
                } else {
                    displayname = Util.toScreen(CustomerInfoComInfo.getCustomerInfoname(log_operator), languageidfromrequest);
                }
            } else if (log_operatortype.equals(RobotNodeBiz.operatortype)){
                if (isprint == false) {
                    displayid = log_operator;
                    displayname = Util.toScreen(robotNodeName, languageidfromrequest);
                } else {
                    displayname = Util.toScreen(robotNodeName, languageidfromrequest);
                }
            } else {
                displayname = SystemEnv.getHtmlLabelName(468, languageidfromrequest);
            }
        }

        // 节点操作者有代理 显示的格式为 bagenter->agenter
        logmap.put("isexsAgent", isexsAgent);
        logmap.put("log_agentorbyagentid", log_agentorbyagentid);
        logmap.put("displaybyagentname", displaybyagentname);

        // 节点操作者
        logmap.put("isinneruser", isinneruser);
        logmap.put("displayid", displayid);
        logmap.put("displayname", displayname);

        // 操作者部门
        logmap.put("displaydepid", displaydepid);
        logmap.put("displaydepname", displaydepname);
    }

    public HttpServletRequest getRequest() {
        return request;
    }

    public void setRequest(HttpServletRequest request) {
        this.request = request;
    }

    public Map<String, String> getOperateMenuName(int tempnodeid, int language){
        Map<String, String> operateNmae = new HashMap<>();

        RightMenu rightMenu = new RightMenu();
        rightMenu.setSystemMenuType(SystemMenuType.FORWARD);
        rightMenu.setSystemSmallType(2);
        String forwardName = MenuOrderSetUtil.getLogName(Util.getIntValue(workflowid),tempnodeid,language,rightMenu);
        operateNmae.put("forwardName",forwardName);
        return operateNmae;
    }

    public static void main(String[] args){
        String  value = "2020-10-11 11:22:0.00";
        value = value.substring(0,10);
        System.out.println("value2222:"+value);
    }
}